#!//usr/local/bin/bash

# use this for compiling and deploying weathermap on antg-dev

JAVA_HOME="/usr/java/jdk1.6.0_30"
M2_HOME="/usr/local/apache-maven/apache-maven-2.2.1"
M2="$M2_HOME/bin"
ANT_HOME="/usr/local/ant/apache-ant-1.8.2"
PATH="$JAVA_HOME/bin:$M2:$ANT_HOME/bin:$PATH"

mvn clean
mvn install

WEBAPP_SRC="src/main/webapp"

#substitute weathermap key
KEY=`cat $WEBAPP_SRC/weathermap.key`
sed -e "s/key=.*\&amp/key=$KEY\&amp/g" < $WEBAPP_SRC/index-flex.html > index.tmp
mv index.tmp $WEBAPP_SRC/index-flex.html
sed -e "s/key=.*\"/key=$KEY\"/g" < $WEBAPP_SRC/index-flex.html > index.tmp
mv index.tmp $WEBAPP_SRC/index-flex.html
cat $WEBAPP_SRC/index-flex.html > mytemp.tmp
sed -e "s/key=.*/key=$KEY\&amp/g" < $WEBAPP_SRC/index.html > index.tmp
mv index.tmp $WEBAPP_SRC/index.html
cat $WEBAPP_SRC/index.html > mytemp1.tmp
